package org.baicaixiaozhan.springbootwebdemo1.exception;

import org.baicaixiaozhan.springbootwebdemo1.util.ResultTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理类 (示例)
 *
 * @author baicaixiaozhan
 * @since 2021/1/29
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResultTemplate<Object> handleException(Exception e) {
        return ResultTemplate.error(HttpStatus.INTERNAL_SERVER_ERROR,
                e.getMessage());
    }
}
